{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\js0072\OneDrive - University of Surrey\Desktop\Full replica\results\BB_replication_nozeros.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}16 Jun 2022, 07:15:10
{txt}r; t=0.00 7:15:10
{com}. use "$dtapath\BB_allyears_all_nozeros_nomirror.dta", replace
{txt}r; t=0.19 7:15:10
{com}. {c )-}
{txt}r; t=0.20 7:15:10

{com}. 
. 
.         drop if year>2000  // B&B use data from 1960-2000. After we drop all years 
{txt}(2,317,718 observations deleted)
r; t=0.34 7:15:11

{com}.         * after 2000, we have data for 1962, 1965, 1970, 1975, 1980, 1985, 1990, and 2000.
.         
.         * collapse the data and take logs to get (log) aggregate bilateral trade flows (B&B's main dependent variable)
.         collapse (sum) imports (mean)  comlang_off comcol curcol col45 distw EIA WTO_j WTO_i WTO PTA scott_fta fta, by(importeriso3 exporteriso3 year)
{txt}r; t=10.79 7:15:22

{com}.         
.         egen pairid_str=concat(exporteriso3 importeriso3)
{txt}r; t=0.03 7:15:22

{com}.         encode pairid_str, gen(pairid)
{txt}r; t=0.07 7:15:22

{com}.         egen exp = concat(exporteriso3 year)
{txt}r; t=0.04 7:15:22

{com}.         egen imp = concat(importeriso3 year)
{txt}r; t=0.05 7:15:22

{com}.         encode exp, gen(ct_exp)
{txt}r; t=0.02 7:15:22

{com}.         encode imp, gen(ct_imp)
{txt}r; t=0.02 7:15:22

{com}.         xtset pairid year
{res}{txt}{col 8}panel variable:  {res}pairid (unbalanced)
{txt}{col 9}time variable:  {res}{col 25}year, 1962 to 2000, but with gaps
{txt}{col 17}delta:  {res}1 unit
{txt}r; t=0.06 7:15:22

{com}.         
.         bys importeriso3 exporteriso3 (year): gen l1fta=fta[_n-1] if year==year[_n-1]+5 | (year==1965 & year==year[_n-1]+3)
{txt}(11,712 missing values generated)
r; t=0.03 7:15:22

{com}.         bys importeriso3 exporteriso3 (year): gen l2fta=fta[_n-2] if year==year[_n-2]+10 | (year==1970 & year==year[_n-2]+8)
{txt}(20,234 missing values generated)
r; t=0.01 7:15:22

{com}.         bys importeriso3 exporteriso3 (year): gen f1fta=fta[_n+1] if year==year[_n+1]-5 | (year==1962 & year==year[_n+1]-3)
{txt}(11,712 missing values generated)
r; t=0.01 7:15:22

{com}.         
.         
.         gen limports=log(imports)
{txt}r; t=0.00 7:15:22

{com}.         sum

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 8}year {c |}{res}     52,125    1982.496    12.31245       1962       2000
{txt}importeriso3 {c |}{res}          0
{txt}exporteriso3 {c |}{res}          0
{txt}{space 5}imports {c |}{res}     52,125    3.59e+08    2.86e+09         10   2.02e+11
{txt}{space 1}comlang_off {c |}{res}     52,125    .1765755    .3813127          0          1
{txt}{hline 13}{c +}{hline 57}
{space 6}comcol {c |}{res}     52,125    .0682782    .2522251          0          1
{txt}{space 6}curcol {c |}{res}     52,125    .0005947    .0243799          0          1
{txt}{space 7}col45 {c |}{res}     52,125    .0133333    .1146988          0          1
{txt}{space 7}distw {c |}{res}     52,125    7693.837    4503.215   160.9283   19650.13
{txt}{space 9}EIA {c |}{res}     51,319   -6.893548    85.12474       -999          6
{txt}{hline 13}{c +}{hline 57}
{space 7}WTO_j {c |}{res}     52,125    .7766906     .416468          0          1
{txt}{space 7}WTO_i {c |}{res}     52,125    .7451511    .4357804          0          1
{txt}{space 9}WTO {c |}{res}     52,125    .5903501    .4917738          0          1
{txt}{space 9}PTA {c |}{res}     50,944    .0893923    .2853119          0          1
{txt}{space 3}scott_fta {c |}{res}     52,125    .0356835    .1855015          0          1
{txt}{hline 13}{c +}{hline 57}
{space 9}fta {c |}{res}     52,125    .0509161    .2198285          0          1
{txt}{space 2}pairid_str {c |}{res}          0
{txt}{space 6}pairid {c |}{res}     52,125    4254.287    2464.521          1       8585
{txt}{space 9}exp {c |}{res}          0
{txt}{space 9}imp {c |}{res}          0
{txt}{hline 13}{c +}{hline 57}
{space 6}ct_exp {c |}{res}     52,125    423.5314    244.8207          1        850
{txt}{space 6}ct_imp {c |}{res}     52,125    335.3871    196.1521          1        676
{txt}{space 7}l1fta {c |}{res}     40,413    .0467176     .211036          0          1
{txt}{space 7}l2fta {c |}{res}     31,891    .0417986    .2001318          0          1
{txt}{space 7}f1fta {c |}{res}     40,413    .0609457    .2392337          0          1
{txt}{hline 13}{c +}{hline 57}
{space 4}limports {c |}{res}     52,125    15.58536    3.500468   2.302585   26.03109
{txt}r; t=0.02 7:15:22

{com}.         
.         *  replicate key B&B regression (their Table 5, col. 4)
.         
.         reghdfe limports fta l1fta l2fta f1fta , abs(ct_exp ct_imp pairid)
{res}{txt}(dropped 562 {browse "http://scorreia.com/research/singletons.pdf":singleton observations})
{res}{txt}({browse "http://scorreia.com/research/hdfe.pdf":MWFE estimator} converged in 9 iterations)
{res}
{txt}HDFE Linear regression{col 51}Number of obs{col 67}= {res}    24,497
{txt}Absorbing 3 HDFE groups{col 51}F({res}   4{txt},{res}  18525{txt}){col 67}= {res}     23.70
{txt}{col 51}Prob > F{col 67}= {res}    0.0000
{txt}{col 51}R-squared{col 67}= {res}    0.9324
{txt}{col 51}Adj R-squared{col 67}= {res}    0.9106
{txt}{col 51}Within R-sq.{col 67}= {res}    0.0051
{txt}{col 51}Root MSE{col 67}= {res}    0.8711

{txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{col 1}    limports{col 14}{c |}      Coef.{col 26}   Std. Err.{col 38}      t{col 46}   P>|t|{col 54}     [95% Con{col 67}f. Interval]
{hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{space 9}fta {c |}{col 14}{res}{space 2} .3510828{col 26}{space 2} .0616987{col 37}{space 1}    5.69{col 46}{space 3}0.000{col 54}{space 4} .2301477{col 67}{space 3}  .472018
{txt}{space 7}l1fta {c |}{col 14}{res}{space 2} .0787659{col 26}{space 2} .0705434{col 37}{space 1}    1.12{col 46}{space 3}0.264{col 54}{space 4}-.0595056{col 67}{space 3} .2170374
{txt}{space 7}l2fta {c |}{col 14}{res}{space 2} .3365318{col 26}{space 2} .0724219{col 37}{space 1}    4.65{col 46}{space 3}0.000{col 54}{space 4} .1945781{col 67}{space 3} .4784854
{txt}{space 7}f1fta {c |}{col 14}{res}{space 2}-.0120037{col 26}{space 2} .0571328{col 37}{space 1}   -0.21{col 46}{space 3}0.834{col 54}{space 4}-.1239893{col 67}{space 3} .0999819
{txt}{space 7}_cons {c |}{col 14}{res}{space 2} 16.83034{col 26}{space 2} .0081101{col 37}{space 1} 2075.24{col 46}{space 3}0.000{col 54}{space 4} 16.81445{col 67}{space 3} 16.84624
{txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{res}
{txt}Absorbed degrees of freedom:
{res}{col 1}{text}{hline 13}{c TT}{hline 12}{hline 12}{hline 14}{hline 1}{c TRC}
{col 1}{text} Absorbed FE{col 14}{c |} Categories{col 27} - Redundant{col 39}  = Num. Coefs{col 54}{c |}
{res}{col 1}{text}{hline 13}{c +}{hline 12}{hline 12}{hline 14}{hline 1}{c RT}
{col 1}{text}      ct_exp{col 14}{c |}{space 1}      562{col 27}{space 1}        0{col 39}{result}{space 1}      562{col 53}{text} {col 54}{c |}
{res}{col 1}{text}      ct_imp{col 14}{c |}{space 1}      350{col 27}{space 1}        6{col 39}{result}{space 1}      344{col 53}{text} {col 54}{c |}
{res}{col 1}{text}      pairid{col 14}{c |}{space 1}     5158{col 27}{space 1}       96{col 39}{result}{space 1}     5062{col 53}{text}?{col 54}{c |}
{res}{col 1}{text}{hline 13}{c BT}{hline 12}{hline 12}{hline 14}{hline 1}{c BRC}
? = number of redundant parameters may be higher
{res}{txt}r; t=0.71 7:15:23

{com}.         
.         * total FTA effect 
.         
.         disp _b[fta]+_b[l1fta]+_b[l2fta]
{res}.76638048
{txt}r; t=0.00 7:15:23

{com}. 
.         *for comparison, (B&B (2007, JIE) get a total FTA effect of 0.28+0.27+0.21 = 0.76 (log points)
.         
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\js0072\OneDrive - University of Surrey\Desktop\Full replica\results\BB_replication_nozeros.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}16 Jun 2022, 07:15:23
{txt}{.-}
{smcl}
{txt}{sf}{ul off}